package com.example.shop_2305.adapter

import android.graphics.Color
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_base.entity.CategoryEntityItem
import com.example.shop_2305.R

class OneAdapter:BaseQuickAdapter<CategoryEntityItem,BaseViewHolder>(R.layout.item_one) {
    var selectId = 515
    override fun convert(holder: BaseViewHolder, item: CategoryEntityItem) {
        holder.setText(R.id.one_tv,item.name)
        if(item.id==selectId){
            holder.setTextColor(R.id.one_tv, Color.RED)
            holder.getView<LinearLayout>(R.id.one_ll).setBackgroundResource(R.drawable.bg_one)
        }else{
            holder.setTextColor(R.id.one_tv, Color.BLACK)
            holder.getView<LinearLayout>(R.id.one_ll).background = null
        }
    }

    fun setId(id:Int){
        selectId = id
        notifyDataSetChanged()
    }
}